package com.xjoyt.pay.master.po;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xjoyt.pay.constants.DateConstant;

/**
 * 商户通道
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_merchant_channel")
public class MerchantChannel {

//	@Id
//	@GeneratedValue(generator = "uuid")
//	@GenericGenerator(name = "uuid", strategy = "uuid2")
//	@Column(name = "merchant_channel_id", length = 36)
//	public String id;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "merchant_channel_id", length = 36)
	public Long id;
	
	

	/**
	 * 商户
	 */
	@ManyToOne(targetEntity = Merchant.class, cascade = {})
	@JoinColumn(name = "merchant_id", foreignKey = @ForeignKey(name = "none"))
	public Merchant merchant;

	/**
	 * 通道
	 */
	@ManyToOne(targetEntity = Channel.class, cascade = {})
	@JoinColumn(name = "channel_id", foreignKey = @ForeignKey(name = "none"))
	public Channel channel;

	/**
	 * 费率
	 */
	@OneToMany(targetEntity = MerchantChannelRate.class, cascade = { CascadeType.REMOVE })
	@JoinColumn(name = "merchant_channel_id", foreignKey = @ForeignKey(name = "none"))
	@JsonIgnore
	public List<MerchantChannelRate> rates;

	/**
	 * 通道商户号
	 */
	@Column(name = "no", length = 255)
	public String no;

	/**
	 * 通道密钥
	 */
	@Column(name = "sign_key", length = 255)
	public String key;

	/**
	 * 状态：激活、停用
	 */
	@Column(name = "is_enabled")
	@org.hibernate.annotations.Type(type = "yes_no")
	public Boolean enabled;

	/**
	 * 录入日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "added_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date addedDate;
}
